package com.atguigu.cloud.order.feign;

import com.atguigu.cloud.order.feign.fallback.UserFeignClientFallback;
import com.atguigu.cloud.user.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 声明当前接口是一个访问SpringCloud-User模块的feign的客户端
 * java代码形式配置feign局部日志级别： @FeignClient(value = "cloud-user",configuration = DefaultFeignConfiguration.class)
 *
 * @author Taeyang
 * @date 2025/4/5
 */
@FeignClient(value = "cloud-user", fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

    /**
     * 远程调用代理
     * 根据userId查询用户信息的接口方法
     *
     * @param userId 用户id
     * @return 用户信息
     */
    @GetMapping(value = "/api/user/findUserByUserId/{userId}")
    User queryById(
            @PathVariable(value = "userId") Long userId,
            @RequestHeader(name = "Truth") String header
    );
}
